CC=arm-linux-gnueabihf-gcc
#CC = gcc

LD = arm-linux-gnueabihf-gcc
CFLAGS = -c -Iinc
LDFLAGS = -lpthread -lm -lrt#还可以加入INCLUDES和LIBS变量，视情况而定
SRCS = $(wildcard src/*.c)  #SRCS的值就是当前面目录下面所有的以.c结尾的源文件
OBJS = $(patsubst %c,%o,$(SRCS))  #SRCS目录下创建c文件相对的o文件
TARGET = em9118ad   #最终链接生成的目标名
.PHONY: all clean

all: $(TARGET) da kda com io
$(TARGET): $(OBJS) main.c
	$(LD) $(LDFLAGS) -o $@ $^
da: em9118da
em9118da: $(OBJS) dawave.c
	$(LD) $(LDFLAGS) -o $@ $^

kda: $(OBJS) kda.c
	$(LD) $(LDFLAGS) -o $@ $^
	
io: em9118io
em9118io: $(OBJS) em9118io.c
	$(LD) $(LDFLAGS) -o $@ $^

com: testcom
testcom: testcom.c src/serial.c src/gpio.c
	$(LD) $(LDFLAGS) -o $@ $^

485: test485
test485: test485.c src/serial.c src/gpio.c
	$(LD) $(LDFLAGS) -o $@ $^

%o: %c
	$(CC) $(CFLAGS) -o $@ $<

clean:
	@rm -f src/*.o $(TARGET) em9118da em9118io
